home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / surpratk.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  11KB  |  337 lines

  1. /***************************************************************************
  2.  
  3. Surprise Attack (Konami GX911) (c) 1990 Konami
  4.  
  5. Very similar to Parodius
  6.  
  7. driver by Nicola Salmoria
  8.  
  9. ***************************************************************************/
  10.  
  11. #include "driver.h"
  12. #include "vidhrdw/generic.h"
  13. #include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
  14. #include "vidhrdw/konamiic.h"
  15.  
  16. /* prototypes */
  17. static void surpratk_init_machine( void );
  18. static void surpratk_banking( int lines );
  19. int surpratk_vh_start( void );
  20. void surpratk_vh_stop( void );
  21. void surpratk_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  22.  
  23.  
  24. static int videobank;
  25. static unsigned char *ram;
  26.  
  27. static int surpratk_interrupt(void)
  28. {
  29.     if (K052109_is_IRQ_enabled()) return interrupt();
  30.     else return ignore_interrupt();
  31. }
  32.  
  33. static READ_HANDLER( bankedram_r )
  34. {
  35.     if (videobank & 0x02)
  36.     {
  37.         if (videobank & 0x04)
  38.             return paletteram_r(offset + 0x0800);
  39.         else
  40.             return paletteram_r(offset);
  41.     }
  42.     else if (videobank & 0x01)
  43.         return K053245_r(offset);
  44.     else
  45.         return ram[offset];
  46. }
  47.  
  48. static WRITE_HANDLER( bankedram_w )
  49. {
  50.     if (videobank & 0x02)
  51.     {
  52.         if (videobank & 0x04)
  53.             paletteram_xBBBBBGGGGGRRRRR_swap_w(offset + 0x0800,data);
  54.         else
  55.             paletteram_xBBBBBGGGGGRRRRR_swap_w(offset,data);
  56.     }
  57.     else if (videobank & 0x01)
  58.         K053245_w(offset,data);
  59.     else
  60.         ram[offset] = data;
  61. }
  62.  
  63. static WRITE_HANDLER( surpratk_videobank_w )
  64. {
  65. logerror("%04x: videobank = %02x\n",cpu_get_pc(),data);
  66.     /* bit 0 = select 053245 at 0000-07ff */
  67.     /* bit 1 = select palette at 0000-07ff */
  68.     /* bit 2 = select palette bank 0 or 1 */
  69.     videobank = data;
  70. }
  71.  
  72. static WRITE_HANDLER( surpratk_5fc0_w )
  73. {
  74.     if ((data & 0xf4) != 0x10) logerror("%04x: 3fc0 = %02x\n",cpu_get_pc(),data);
  75.  
  76.     /* bit 0/1 = coin counters */
  77.     coin_counter_w(0,data & 0x01);
  78.     coin_counter_w(1,data & 0x02);
  79.  
  80.     /* bit 3 = enable char ROM reading through the video RAM */
  81.     K052109_set_RMRD_line( ( data & 0x08 ) ? ASSERT_LINE : CLEAR_LINE );
  82.  
  83.     /* other bits unknown */
  84. }
  85.  
  86.  
  87. /********************************************/
  88.  
  89. static struct MemoryReadAddress surpratk_readmem[] =
  90. {
  91.     { 0x0000, 0x07ff, bankedram_r },
  92.     { 0x0800, 0x1fff, MRA_RAM },
  93.     { 0x2000, 0x3fff, MRA_BANK1 },            /* banked ROM */
  94.     { 0x5f8c, 0x5f8c, input_port_0_r },
  95.     { 0x5f8d, 0x5f8d, input_port_1_r },
  96.     { 0x5f8e, 0x5f8e, input_port_4_r },
  97.     { 0x5f8f, 0x5f8f, input_port_2_r },
  98.     { 0x5f90, 0x5f90, input_port_3_r },
  99. //    { 0x5f91, 0x5f91, YM2151_status_port_0_r },    /* ? */
  100.     { 0x5fa0, 0x5faf, K053244_r },
  101.     { 0x5fc0, 0x5fc0, watchdog_reset_r },
  102.     { 0x4000, 0x7fff, K052109_r },
  103.     { 0x8000, 0xffff, MRA_ROM },            /* ROM */
  104.     { -1 }    /* end of table */
  105. };
  106.  
  107. static struct MemoryWriteAddress surpratk_writemem[] =
  108. {
  109.     { 0x0000, 0x07ff, bankedram_w, &ram },
  110.     { 0x0800, 0x1fff, MWA_RAM },
  111.     { 0x2000, 0x3fff, MWA_ROM },                    /* banked ROM */
  112.     { 0x5fa0, 0x5faf, K053244_w },
  113.     { 0x5fb0, 0x5fbf, K053251_w },
  114.     { 0x5fc0, 0x5fc0, surpratk_5fc0_w },
  115.     { 0x5fd0, 0x5fd0, YM2151_register_port_0_w },
  116.     { 0x5fd1, 0x5fd1, YM2151_data_port_0_w },
  117.     { 0x5fc4, 0x5fc4, surpratk_videobank_w },
  118.     { 0x4000, 0x7fff, K052109_w },
  119.     { 0x8000, 0xffff, MWA_ROM },                    /* ROM */
  120.     { -1 }    /* end of table */
  121. };
  122.  
  123.  
  124. /***************************************************************************
  125.  
  126.     Input Ports
  127.  
  128. ***************************************************************************/
  129.  
  130. INPUT_PORTS_START( surpratk )
  131.     PORT_START    /* PLAYER 1 INPUTS */
  132.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  133.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  134.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  135.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  136.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  137.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  138.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  139.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  140.  
  141.     PORT_START    /* PLAYER 2 INPUTS */
  142.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
  143.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  144.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  145.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  146.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  147.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  148.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  149.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  150.  
  151.     PORT_START    /* DSW #1 */
  152.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  153.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  154.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  155.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  156.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  157.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  158.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  159.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  160.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  161.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  162.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  163.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  164.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  165.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  166.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  167.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  168.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  169.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  170.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  171.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  172.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  173.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  174.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  175.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  176.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  177.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  178.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  179.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  180.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  181.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  182.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  183.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  184.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  185. //    PORT_DIPSETTING(    0x00, "No Use" )
  186.  
  187.     PORT_START    /* DSW #2 */
  188.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  189.     PORT_DIPSETTING(    0x03, "2" )
  190.     PORT_DIPSETTING(    0x02, "3" )
  191.     PORT_DIPSETTING(    0x01, "5" )
  192.     PORT_DIPSETTING(    0x00, "7" )
  193.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  195.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  196.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  197.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  198.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  199.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  200.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  201.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  202.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  203.     PORT_DIPSETTING(    0x60, "Easy" )
  204.     PORT_DIPSETTING(    0x40, "Normal" )
  205.     PORT_DIPSETTING(    0x20, "Difficult" )
  206.     PORT_DIPSETTING(    0x00, "Very Difficult" )
  207.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  208.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  209.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  210.  
  211.     PORT_START    /* DSW #3 */
  212.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
  213.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE )
  214.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
  215.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
  216.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
  217.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  218.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  219.     PORT_DIPNAME( 0x20, 0x20, "Upright Controls" )
  220.     PORT_DIPSETTING(    0x20, "Single" )
  221.     PORT_DIPSETTING(    0x00, "Dual" )
  222.     PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
  223.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  224.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  225.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  226. INPUT_PORTS_END
  227.  
  228.  
  229.  
  230. static void irqhandler(int linestate)
  231. {
  232.     cpu_set_irq_line(0,KONAMI_FIRQ_LINE,linestate);
  233. }
  234.  
  235. static struct YM2151interface ym2151_interface =
  236. {
  237.     1,            /* 1 chip */
  238.     3579545,    /* 3.579545 MHz */
  239.     { YM3012_VOL(50,MIXER_PAN_LEFT,50,MIXER_PAN_RIGHT) },
  240.     { irqhandler },
  241. };
  242.  
  243.  
  244.  
  245. static struct MachineDriver machine_driver_surpratk =
  246. {
  247.     /* basic machine hardware */
  248.     {
  249.         {
  250.             CPU_KONAMI,        /* 053248 */
  251.             3000000,        /* ? */
  252.             surpratk_readmem,surpratk_writemem,0,0,
  253.             surpratk_interrupt,1
  254.         }
  255.     },
  256.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  257.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  258.     surpratk_init_machine,
  259.  
  260.     /* video hardware */
  261.     64*8, 32*8, { 14*8, (64-14)*8-1, 2*8, 30*8-1 },
  262.     0,    /* gfx decoded by konamiic.c */
  263.     2048, 2048,
  264.     0,
  265.  
  266.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  267.     0,
  268.     surpratk_vh_start,
  269.     surpratk_vh_stop,
  270.     surpratk_vh_screenrefresh,
  271.  
  272.     /* sound hardware */
  273.     SOUND_SUPPORTS_STEREO,0,0,0,
  274.     {
  275.         {
  276.             SOUND_YM2151,
  277.             &ym2151_interface
  278.         }
  279.     }
  280. };
  281.  
  282. /***************************************************************************
  283.  
  284.   Game ROMs
  285.  
  286. ***************************************************************************/
  287.  
  288. ROM_START( surpratk )
  289.     ROM_REGION( 0x51000, REGION_CPU1 ) /* code + banked roms + palette RAM */
  290.     ROM_LOAD( "911m01.bin", 0x10000, 0x20000, 0xee5b2cc8 )
  291.     ROM_LOAD( "911m02.bin", 0x30000, 0x18000, 0x5d4148a8 )
  292.     ROM_CONTINUE(           0x08000, 0x08000 )
  293.  
  294.     ROM_REGION( 0x080000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  295.     ROM_LOAD( "911d05.bin", 0x000000, 0x040000, 0x308d2319 ) /* characters */
  296.     ROM_LOAD( "911d06.bin", 0x040000, 0x040000, 0x91cc9b32 ) /* characters */
  297.  
  298.     ROM_REGION( 0x080000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  299.     ROM_LOAD( "911d03.bin", 0x000000, 0x040000, 0xe34ff182 )    /* sprites */
  300.     ROM_LOAD( "911d04.bin", 0x040000, 0x040000, 0x20700bd2 )    /* sprites */
  301. ROM_END
  302.  
  303. /***************************************************************************
  304.  
  305.   Game driver(s)
  306.  
  307. ***************************************************************************/
  308.  
  309. static void surpratk_banking(int lines)
  310. {
  311.     unsigned char *RAM = memory_region(REGION_CPU1);
  312.     int offs = 0;
  313.  
  314. logerror("%04x: setlines %02x\n",cpu_get_pc(),lines);
  315.  
  316.     offs = 0x10000 + ((lines & 0x1f) * 0x2000);
  317.     if (offs >= 0x48000) offs -= 0x40000;
  318.     cpu_setbank(1,&RAM[offs]);
  319. }
  320.  
  321. static void surpratk_init_machine( void )
  322. {
  323.     konami_cpu_setlines_callback = surpratk_banking;
  324.  
  325.     paletteram = &memory_region(REGION_CPU1)[0x48000];
  326. }
  327.  
  328. static void init_surpratk(void)
  329. {
  330.     konami_rom_deinterleave_2(REGION_GFX1);
  331.     konami_rom_deinterleave_2(REGION_GFX2);
  332. }
  333.  
  334.  
  335.  
  336. GAME( 1990, surpratk, 0, surpratk, surpratk, surpratk, ROT0, "Konami", "Surprise Attack (Japan)" )
  337.